var tpl = _include('./index.html');
appendCss(_include('./index.less?_ac=less'));
var uploadimg = require('/src/vue/uploadimg/index.js');

var configCard = {
    template: tpl,
    props:['example', 'frameWindow'],
    mounted: function() {
      // this.createDom('.J_schema');
      console.log(this.frameWindow)
    },

    methods:{
      createDom: function(obj) {
        var htmlStr = '';
        this.example.find(obj).each(function(index, item){
          if($(item).attr('data-type') === 'goodList') {
            // console.log(item)
            return;
          }else {

          }
            var dataSchema = JSON.parse($(item).attr('data-schema')),
                itemId = $(item).attr('data-id');
            if(dataSchema['attr']) {
                }else if(dataSchema['style']) {
                  // console.log(Object.keys(dataSchema['style']))
                  Object.keys(dataSchema['style']).forEach(function(key){
                    var itemData = this.schemaJSON[itemId]['style'][key],
                        itemTitle = dataSchema['style'][key][1],
                        itemType = dataSchema['style'][key][0];
                    if(key === 'background-image') {
                      // console.log(dataSchema['style'][key][1]);
                      //图片
                      htmlStr += '<li data-class="' + itemId + '" data-type="'+ itemType +'" data-action="'+ key +'">' +
                                    '<div><img src="' + itemData + '"/></div>' +
                                    '<span>' + itemTitle + '</span>' +
                                  '</li>';
                    }else {
                      htmlStr += '<li data-class="' + itemId + '" data-type="'+ itemType +'" data-action="'+ key +'">' +
                                    '<div style="'+ key +':'+ itemData +'"></div>' +
                                    '<span>' + itemTitle + '</span>' +
                                  '</li>';
                    }
                  });
                }
        });
        $('.J-configWrap').html(htmlStr);
      },
    }
};

module.exports = configCard;
